package work20241126_27;

import java.util.Arrays;

/**
 * @author zdl
 * @date 2024/11/26
 */
public class Demo16 {
    public static void main(String[] args) {
        //查找数组中是否包含指定元素，返回其索引位置。
        int[] arr = {1,3,5,7,3};
        int[] indexArr = new int[arr.length];
        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == 3){
                indexArr[count++] = i;
            }
        }
        int[] new_arr = new int[count];
        for (int i = 0; i < new_arr.length; i++) {
            new_arr[i] = indexArr[i];
        }
        System.out.println(Arrays.toString(new_arr));
    }
}
